package main

import "fmt"

func main() {
	a, b, c := 1, 2, 3
	s := []int{a, b, c}

	var ss []*int
	for _, i := range s {
		ss = append(ss, &i)
	}

	for _, i := range ss {
		fmt.Println(*i)
	}

}

func f() (r int) {
	t := 5
	defer func() {
		t += 5
	}()

	return t

}

type num int

func (n *num) print() {
	fmt.Println(*n)
}

func test() {

}

var ans = make([]int, 0)

func ansAdd(num int) {
	ans = append(ans, num)
}

func dnf(nu int, n int) {
	if nu <= n {
		ansAdd(nu)
	}

	if nu*10 < n {
		dnf(nu*10, n)
	} else {
		if nu+1 < n && nu%9 != 0 {
			dnf(nu+1, n)
		} else if nu/10 > 0 {
			dnf(nu/10+1, n)
		}
	}
}

func lexicalOrder(n int) []int {

	dnf(1, n)

	return ans
}

func lexicalOrder1(n int) []int {
	ans := make([]int, n)
	num := 1
	for i := range ans {
		ans[i] = num
		if num*10 <= n {
			num *= 10
		} else {
			for num%10 == 9 || num+1 > n {
				num /= 10
			}
			num++
		}
	}
	return ans
}
